<template>
  <view
    :class="showTips ? 'applyParts applyPartsFixed' : 'applyParts'"
    :style="{ overflow: showImg ? 'hidden' : 'auto' }"
  >
    <view class="header">
      <view class="name">{{
        elevtorInfo.buildingName
      }}</view>
<!--      <view class="address">{{ elevtorInfo.buildingAddress }}</view> -->
      <view class="address">{{ elevtorInfo.elevatorAddress }}</view>
    </view>
    <view class="warning-msg" v-if="isReturn == 1">
      <view class="warning-msg-box">
        <view class="warning-msg-text">
          <view class="left">
            <image src="@/static/images/tips.png" mode=""></image>
            <view class="returnMsg">退回理由:{{ returnMsg || "无" }}</view>
          </view>
          <view class="right" @click.stop="returnUp = true" v-if="!returnUp">
            <uni-icons
              color="#FA6400"
              size="16"
              :type="!returnUp ? 'arrowdown' : 'arrowup'"
            ></uni-icons>
          </view>
        </view>
        <scroll-view
          v-if="returnImgUrls && returnImgUrls.length && returnUp"
          scroll-y="true"
          style="height: 70vh"
        >
          <view class="imgBox">
            <image
              v-for="(item, index) in returnImgUrls"
              :key="index"
              :src="item"
              mode="widthFix"
            ></image>
          </view>
        </scroll-view>
        <view
          class="upTips"
          @click="returnUp = false"
          v-if="returnImgUrls && returnImgUrls.length && returnUp"
        >
          <uni-icons color="#FA6400" size="16" :type="'arrowup'"></uni-icons>
          向上收起</view
        >
      </view>
    </view>
    <view class="tabs-view">
      <view class="tab-header">
        <view
          :class="['tab-item', tabIndex === 0 ? 'act' : '']"
          @click="handleTabClick(0)"
        >
          项目地址</view
        >
        <view
          :class="[
            'tab-clip',
            tabIndex === 0 ? 'tab-clip-left' : 'tab-clip-right',
          ]"
        ></view>
        <view
          :class="['tab-item', tabIndex === 1 ? 'act' : '']"
          @click="handleTabClick(1)"
        >
          公司地址</view
        >
      </view>
      <view class="tab-content" v-if="!isEditAddress">
        <view class="tab-title-row">
          <view
            class="address-label"
            :style="{ backgroundColor: tabIndex === 0 ? '#0091FF' : '#FF7505' }"
            >{{ tabIndex === 0 ? "项目" : "公司" }}</view
          >
          <view class="tab-title-con">
            <view class="tab-title">
              <view class="address-title">{{
                addressObj.locationAddress
              }}</view>
              <view class="address-icon" @click="handleEditAddress">
                <image src="/static/edit.png"></image>
              </view>
            </view>
            <view class="tab-desc"
              >{{ addressObj.userName }} {{ addressObj.phone }}</view
            >
          </view>
        </view>
      </view>
      <view v-else>
        <view class="pAddress">
          <view class="add_row">
            <view class="cel_L">收货人</view>
            <view class="cel_R">
              <input
                type="text"
                placeholder="请输入收货人"
                v-model="addressObj.userName"
                placeholder-style="color:#ccc;"
                :disabled="false"
              />
            </view>
          </view>
          <view class="add_row">
            <view class="cel_L">手机号码</view>
            <view class="cel_R">
              <input
                type="text"
                placeholder="请输入手机号"
                v-model="addressObj.phone"
                placeholder-style="color:#ccc;"
                :disabled="false"
              />
            </view>
          </view>
          <view class="add_row">
            <view class="cel_L">所在地区</view>
            <view class="cel_R" @click="openCity">
              <input
                type="text"
                placeholder="请输入所在地区"
                v-model="addressObj.pcAaddress"
                placeholder-style="color:#ccc;"
                :disabled="true"
              />
              <view class="downsr"><text></text></view>
            </view>
          </view>
          <view class="add_row">
            <view class="cel_L">详情地址</view>
            <view class="cel_R">
              <textarea
                type="textarea"
                v-model="addressObj.address"
                placeholder="请输入详情地址"
                placeholder-style="color:#ccc;"
                maxlength="300"
              />
            </view>
          </view>
        </view>
      </view>
      <view v-if="elevatorData.length === 0"
        class="nameplate"
        :style="{ marginLeft: isEditAddress ? '10rpx' : '58rpx' }"
      >
        <view
          ><text v-if="!elevtorInfo.nameAttachmentList.length">*</text
          >电梯铭牌</view
        >
        <!-- 新增 -->
        <!-- <imageBox
          max="1"
          :disabled="elevtorInfo.nameAttachmentList.length"
          :list="nameplateList"
          @changeList="changeNameTemlate($event)"
          tips="上传图片"
        ></imageBox> -->
        <!-- 编辑 -->
        <imageBox
          max="1"
          :list="nameplateList"
		  :disabled="elevtorInfo.disabled"
          @changeList="changeNameTemlate($event)"
          tips="上传图片"
        ></imageBox>
      </view>
    </view>
    <view class="item_parts">
      <template v-if="workShow">
        <view class="title"> <text>*</text>配件任务类型</view>
        <view class="btnBox">
          <view class="btn" v-for="(item, index) in btnBoxLists" :key="index">
            <view
              :class="[
                'btnItem',
                objData.workOrderType == item.key ? 'btnSel' : '',
              ]"
              @click="selectBtn(item.key, 'workOrderType')"
            >
              {{ item.label }}</view
            >
          </view>
        </view>
      </template>
      <template v-if="!objData.fromPlanId">
        <view class="title"> <text>*</text>电梯状态</view>
        <view class="btnBox">
          <view class="btn" v-for="(item, index) in eleStateLists" :key="index">
            <view
              :class="[
                'btnItem',
                objData.elevatorStop == item.key ? 'btnSel' : '',
              ]"
              @click="selectBtn(item.key, 'elevatorStop')"
            >
              {{ item.label }}</view
            >
          </view>
        </view>
      </template>
      <view class="title"> <text>*</text>紧急程度</view>
      <view class="btnBox">
        <view class="btn" v-for="(item, index) in btnBoxList" :key="index">
          <view
            :class="[
              'btnItem',
              objData.emerProcType == item.key ? 'btnSel' : '',
            ]"
            @click="selectBtn(item.key, 'emerProcType')"
            :style="{
              color: item.key == '2' ? '#E02020' : '',
              borderColor:
                objData.emerProcType == '2' && item.key == '2' ? '#E02020' : '',
            }"
          >
            {{ item.label }}</view
          >
        </view>
      </view>
    </view>
    <!-- <view @click="handleClickImg">点击</view> -->
    <view class="item_parts" v-for="(item, index) in itemList" :key="index">
      <view class="item-title">
        <view class="title">
          配件明细
          <view class="serial-num">{{ index + 1 }}</view>
        </view>
        <view class="item-op">
          <view
            class="del"
            v-if="isReturn != 1 && !planIdEdit"
            @click="handleDel(item, index)"
          >
            <image src="@/static/images/del.png" mode="widthFix"></image>
          </view>
          <!-- <view @click="handleClickImg">点击打开</view> -->
          <view class="expanded" @click="handleExpanded(item, index)">
            {{ item.isMore ? "收起" : "展开" }}
            <view class="downs" :class="item.isMore ? 'downs-act' : ''"
              ><text></text
            ></view>
          </view>
        </view>
      </view>
      <view class="item-content">
        <view class="item-col">
          <view class="title">
            <view class="title_left"> <text>*</text>选择配件类型</view>
          </view>

          <view class="item-input" @click="selectPartsClick(item, index)">
            <!-- <view class="partsNumber_input" >
              <input type="text" placeholder="请选择配件" v-model="objData.partsName" placeholder-style="color:#ccc"
                :style="{ color: (objData.disabled || planIdEdit && objData.malDetailVO.planId) ? '#ccc' : '' }" :disabled="true" />
            </view> -->
            <view
              class="innerText"
              :class="
                objData.disabled ||
                objData.fromPlanId ||
                (planIdEdit && objData.malDetailVO.planId)
                  ? 'inp-disabled'
                  : ''
              "
              :style="{ color: !item.partsName ? '#ccc' : '#333' }"
            >
              {{ item.partsName || "请选择配件类型" }}
              <text v-if="item.floorStandNames"
                >({{ item.floorStandNames.replaceAll(",", ">") }})</text
              >
            </view>
            <view class="downs"><text></text></view>
          </view>
        </view>
        <template v-if="item.isMore">
          <view class="item-col" v-if="item.categoryId && item.skuList.length">
            <view class="title_js">
              <view class="title_text">选择配件</view>
              <view class="btn_text" @click="handleClickDefault(item, index)">
                <image
                  src="@/static/images/maintain/zk.png"
                  mode="widthFix"
                ></image>
                <view>自定义填写</view>
              </view>
            </view>
            <view class="item-input" @click="handleClickSku(item, index)">
              <!-- <view class="partsNumber_input" >
                <input type="text" placeholder="请选择配件" v-model="objData.partsName" placeholder-style="color:#ccc"
                  :style="{ color: (objData.disabled || planIdEdit && objData.malDetailVO.planId) ? '#ccc' : '' }" :disabled="true" />
              </view> -->
              <view
                class="innerText"
                :class="
                  !item.skuList || item.skuList.length === 0
                    ? 'inp-disabled'
                    : ''
                "
                :style="{ color: !item.skuName ? '#ccc' : '#333' }"
              >
                {{ item.skuName || "请选择配件" }}
              </view>
              <view class="downs"><text></text></view>
            </view>
            <view class="notes"
              >填当前电梯已关联配件信息，请选择或自定义填写</view
            >
          </view>
          <view class="item-col" v-if="item.spuName">
            <view class="title">配件名称</view>
            <view class="item-input">
              <view class="innerText">
                {{ item.spuName }}
              </view>
            </view>
            <view class="notes"
              >填当前电梯已关联配件信息，请选择或自定义填写</view
            >
          </view>
          <view
            class="item-col"
            v-else-if="
              !item.categoryId ||
              ((!item.skuList || item.skuList.length === 0) &&
                item.templateList.length === 0)
            "
          >
            <view class="title">
              <view class="title_left"> <text>*</text>配件品牌型号</view>
            </view>

            <view class="item-input">
              <input
                type="text"
                placeholder="请务必按「品牌;型号;规格」格式进行配件型号录入"
                v-model="item.partsModel"
                placeholder-style="color:#ccc"
                :disabled="false"
              />
            </view>
            <view class="notes"><text>注：</text>符号输入：仅支持英文符号</view>
            <view class="notes"><text></text>填写示例：虏克;LIOP;外呼板</view>
          </view>
          <block v-for="(form, i) in item.templateList" :key="form.key">
            <block v-if="item.skuId ? form.value : true">
              <view
                class="item-col"
                v-if="form.type === 'input' || form.type === 'number'"
              >
                <view class="title">
                  <view class="name">
                    <text v-if="form.required">*</text>
                    {{ form.label }}
                  </view>
                  <view
                    class="imgs"
                    v-if="form.imgs && form.imgs.length"
                    @click="handleClickImg(form, i)"
                  >
                    <image
                      class="add-icon"
                      src="/static/images/tips3.svg"
                    ></image>
                    如何获取/测量</view
                  >
                </view>
                <view class="item-input">
                  <input
                    :type="form.type === 'input' ? 'text' : 'number'"
                    :placeholder="form.placeholder"
                    v-model="form.value"
                    placeholder-style="color:#ccc"
                    :disabled="!item.isDefault"
                  />
                  <view
                    class="unit"
                    :class="!item.isDefault ? 'inp-disabled' : ''"
                    v-if="form.unitName"
                    >{{ form.unitName }}({{ form.unitCnName }})</view
                  >
                </view>
              </view>
              <view class="item-col" v-else-if="form.type === 'select'">
                <view class="title">
                  <view class="name">
                    <text v-if="form.required">*</text>
                    {{ form.label }}
                  </view>
                  <view
                    class="imgs"
                    v-if="form.imgs && form.imgs.length"
                    @click="handleClickImg(form, i)"
                  >
                    <image
                      class="add-icon"
                      src="/static/images/tips3.svg"
                    ></image>
                    如何获取/测量</view
                  >
                </view>
                <view
                  class="item-input"
                  @click="handleClickPicker(form, i, item, index)"
                >
                  <view
                    class="innerText"
                    :class="!item.isDefault ? 'inp-disabled' : ''"
                    :style="{ color: !form.value ? '#ccc' : '#333' }"
                  >
                    {{ form.value ? form.valueName : form.placeholder }}
                  </view>
                  <view class="downs"><text></text></view>
                </view>
              </view>
            </block>
          </block>
          <view class="item-col">
            <view class="title">
              <view class="title_left"> <text>*</text>电梯配件数量</view>
            </view>

            <view class="numBtn">
              <uni-number-box
                :min="1"
                :max="100"
                v-model="item.num"
              ></uni-number-box>
            </view>
          </view>
          <view class="item-col">
            <view class="title">
              <view class="title_left"> <text>*</text>计量单位</view>
            </view>

            <view class="item-input" @click="handleUnitClick(index)">
              <input
                type="text"
                placeholder="请选择计量单位"
                v-model="item.unitNameValue"
                placeholder-style="color:#ccc;"
                :disabled="true"
                class="unit-input"
              />
            </view>
          </view>

          <view class="item-col">
            <view class="title">
              <view class="title_left"> <text>*</text>配件照片/视频</view>
            </view>
            <view class="parts_img">
              <imageDragSort
                :max="9"
                :disabled="
                  !!(item.skuId && item.otherUrl.length && !item.isDefault)
                "
                :list="item.otherUrl"
                @changeList="handleChangeImg($event, item, index)"
                tips="上传图片"
              ></imageDragSort>
            </view>
          </view>
          <view class="item-col" v-if="item.isDefault || !item.skuId">
            <view class="title">备注<text class="color_999">(选填)</text></view>
            <view class="item-input">
              <textarea
                type="textarea"
                v-model="item.desc"
                height="108rpx"
                placeholder="请输入备注内容"
                placeholder-class="textare"
                maxlength="300"
              />
              <view class="length">{{
                item.desc ? item.desc.length : "0" + "/300"
              }}</view>
            </view>
          </view>
        </template>
      </view>
    </view>
    <view
      class="item_parts add-btn-body"
      v-if="isReturn != 1 && !planIdEdit"
      @click="handleClickAdd"
    >
      <view class="add-btn">
        <image class="add-icon" src="/static/images/specials/add.svg"></image>
        <text>添加配件</text>
      </view>
    </view>
    <!--
    <view class="item_partsModel">
      <view class="title"><text>*</text>配件品牌型号</view>
      <view class="partsNumber_input">
        <input type="text" placeholder="请务必按「品牌;型号;规格」格式进行配件型号录入" v-model="objData.partsModel"
          placeholder-style="color:#ccc" :disabled="false" />
      </view>
      <view class="notes"><text>注：</text>符号输入：仅支持英文符号</view>
      <view class="notes"><text></text>填写示例：虏克;LIOP;外呼板</view>
    </view>
    <view class="item_partsNumber">
      <view class="title"><text>*</text>电梯配件数量</view>
      <view class="numBtn">
        <uni-number-box :min="1" :max="100" @change="changeNumber" v-model="objData.num"></uni-number-box>
      </view>
    </view>
    <view class="item_partsimg">
      <view class="title"><text>*</text>更换配件照片/视频
      </view>
      <view class="parts_img">
        <imageDragSort max="9" :list="imgUrls" @changeList="changeImg" tips="上传图片"></imageDragSort>
      </view>
    </view>
    <view class="item_remarks">
      <view class="title">备注<text>(选填)</text></view>
      <view class="remarks">
        <textarea type="textarea" v-model="objData.desc" height="108rpx" placeholder="请输入备注内容"
          placeholder-class="textare" maxlength="300" />
        <view class="length">{{ objData.desc ? objData.desc.length : '0' + "/300" }}</view>
      </view>
    </view>
    <view class="item_remarks">
      <view class="title"><text class="rot">*</text>配件收货地址</view>
      <view class="tabs">
        <view :class="['tabs-item', statusActive == 0 ? 'act' : '']" @click="changeStatus(0)">公司地址</view>
        <view :class="['tabs-item', statusActive == 1 ? 'act' : '']" @click="changeStatus(1)">项目地址</view>
      </view>
        -->
    <!-- <view class="approveStatus">
        <view v-for="(item, index) in ['公司地址','项目地址']" :key="index"
          :class="[statusActive === index ? 'apptop active' : 'apptop']" @click="changeStatus(index)">{{ item }}
        </view>
      </view> -->
    <!--
      <view class="pAddress" v-if="statusActive >= 0">
        <view class="add_row">
          <view class="cel_L">收货人</view>
          <view class="cel_R">
            <input type="text" placeholder="请输入收货人" v-model="addressObj.userName" placeholder-style="color:#ccc;"
              :disabled="false" />
          </view>
        </view>
        <view class="add_row">
          <view class="cel_L">手机号码</view>
          <view class="cel_R">
            <input type="text" placeholder="请输入手机号" v-model="addressObj.phone" placeholder-style="color:#ccc;"
              :disabled="false" />
          </view>
        </view>
        <view class="add_row">
          <view class="cel_L">所在地区</view>
          <view class="cel_R" @click="openCity">
            <input type="text" placeholder="请输入所在地区" v-model="addressObj.pcAaddress" placeholder-style="color:#ccc;"
              :disabled="true" />
            <view class="downsr"><text></text></view>
          </view>
        </view>
        <view class="add_row">
          <view class="cel_L">详情地址</view>
          <view class="cel_R">
            <textarea type="textarea" v-model="addressObj.address" placeholder="请输入详情地址" placeholder-style="color:#ccc;"
              maxlength="300" />
          </view>
        </view>
      </view>
    </view>
     -->
    <!-- 
    <view class="item_information">
      <view class="title">审批信息</view>
      <view class="information_title">
        <view class="title_name"><text></text>维保组长</view>
        <view class="title_uname">
          <text>{{
            userData.role_name != "maintenance"
            ? userData.nick_name.substring(0, 2)
            : groupObj &&
            groupObj.groupApproveNames &&
            groupObj.groupApproveNames.substring(0, 2)
          }}</text>
          <text>{{
            userData.role_name != "maintenance"
            ? userData.nick_name
            : groupObj.groupApproveNames
          }}</text>
        </view>
      </view>
    </view>
     -->
    <view class="item_tips">
      <view class="tips" v-if="userinfo.role_name == 'maintenance'"
        >提示：提交报障后，将由上级进行审批，可在-个人头像-我的申请-配件申请，查看提交的配件申请</view
      >
      <view class="tips" v-else
        >提示：提交配件后，将由报价员进行报价，可在-个人头像-我的申请-配件申请，查看提交的配件申请</view
      >
    </view>

    <view class="block"></view>
    <view class="BA_item_botm" @click="submitClicksr">
      <view :class="btnStatus ? 'botm botms' : 'botm'">{{
        isReturn == 1 ? "重新提交" : planIdEdit ? "确定" : "申请配件"
      }}</view>
    </view>

    <!-- 弹窗提示 -->
    <model
      title="提示"
      :maskClick="false"
      @cancle="cancle"
      @comfire="comfire"
      :visible="visibleShow"
    >
      <view class="modelCont">
        <view>{{
          isReturn == 1
            ? "是否确认重新提交配件信息？"
            : planIdEdit
            ? "是否确认修改配件信息？"
            : "是否确认提交配件信息？"
        }}</view>
        <view>注:请确认是否填写好配件名称/规格型号/数量及配件图片</view>
      </view>
    </model>
    <!-- 省市区 -->
    <cityPicker
      ref="cityPicker"
      :column="column"
      :default-value="defaultValue"
      :visible="visible"
      :mask-close-able="maskCloseAble"
      @confirm="confirmCity"
      @cancel="cancelCity"
    />
    <!-- 弹窗提示 -->
    <!-- <ui-container> -->
    <dialogTips v-if="showTips" :showTips="showTips" @closed="closed" />
    <!-- </ui-container> -->
    <previewMedia ref="previewMedia"></previewMedia>
    <!-- S-选择配件弹出框 -->
    <uni-popup ref="pickPopup" type="bottom">
      <select-picker
        :title="pickData.title"
        :isSearch="pickData.isSearch"
        :searchPlaceholder="pickData.searchPlaceholder"
        :active="pickData.value"
        :list="pickData.list"
        @close="handlePickerClose"
        @handleSearch="handlePickerSearch"
      >
      </select-picker>
    </uni-popup>
    <!-- E-层站门弹出框 -->
    <!-- 指引图片弹窗 -->
    <!-- <imgDialog
      v-if="showImg"
      :show="showImg"
      :list="imgList"
      @closed="showImg = false"
      ref="imgDialog"
    ></imgDialog> -->
    <uni-popup
      ref="popupImg"
      type="bottom"
      background-color="#fff"
      @change="handlePopupChange"
    >
      <imgDialog
        :show="showImg"
        :list="imgList"
        @closed="closeImg"
        ref="imgDialog"
      ></imgDialog>
    </uni-popup>
    <uni-popup ref="unitPopup" type="bottom" background-color="#fff">
      <unitPopup @close="confirmUnit" @submit="submitUnit" ref="unitDetail"></unitPopup>
    </uni-popup>
  </view>
</template>

<script>
import { mapState, mapActions } from 'vuex';
import unitPopup from './components/unitDialog.vue';
import imageDragSort from '@/components/image-drag-sort/img-and-video.vue';
import imageBox from '@/components/image-drag-sort/index.vue';
import model from '@/components/model/index.vue';
import cityPicker from '@/uni_modules/piaoyi-cityPicker/components/piaoyi-cityPicker/piaoyi-cityPicker';
import dialogTips from './components/dialogTips.vue';
import imgDialog from './components/imgDialog.vue';
import {
	partsStart,
	partsMyAuditDetail,
	partsMyAuditDetailWork,
	partsCompanyAddress,
	getSkuTemplate,
	getSkuDetail,
	getSkuList,
	partsResubmit,
	getSkuOptions,
} from '@/apis/parts.js';
import { getBuilding } from '@/apis/building.js';
import { hanleToken } from '@/utils/utils.js';
import { getApproveUserData } from '@/apis/barrierSearch.js';
import { elevtorDetail } from '@/apis/elevator.js';
import uniPopup from '@/components/uni-popup/uni-popup';
import selectPicker from '@/pageModules/components/select-picker/select-picker.vue';

export default {
	name: 'applyParts',
	components: {
		selectPicker,
		uniPopup,
		imageDragSort,
		model,
		cityPicker,
		dialogTips,
		imgDialog,
		imageBox,
		unitPopup,
		// uicontainer
	},
	data() {
		return {
			// 编辑的时候铭牌展示是否展示,elevatorAttachmentHistory.attachment==null的话就拿maintainPlanContentExt.elevatorNameAttachment
			editMingObj: {
				elevatorNameAttachment: '',
				nameAttachmentList: [],
			},
			selectedUnit:{
				label:'',
				value:''
			},
			returnUp: false,
			// 退回图片
			returnImgUrls: [],
			// 预览的图片
			nameplateList: [],
			imgList: [],
			showImg: false,
			objData: {
				elevatorId: '',
				// 配件id
				// partsId: '',
				// // 配件名称
				// partsName: '',
				// // 自定义名字
				// name: '',
				// // 型号
				// partsModel: '',
				// // 电梯配件数量
				// num: 1,
				// desc: '',
				// otherUrl: [],
				// 工单id
				fromPlanId: '',
				// 审批详情id
				approveId: '',
				// 工单id
				wxPlanId: '',
				// 任务类型
				workOrderType: '',
				// 紧急程度
				emerProcType: '',
				// 内部整改类型
				planTypeDesc: '',
				// 电梯状态
				elevatorStop: '',
				malDetailVO: null,
				// 单位的id
				unitValue:''
			},
			// 紧急程度标签
			btnBoxList: [
				// { color: '#e02020', bgColor: '#ffecec', label: '非常紧急', key: '1', },
				{ color: '#e02020', bgColor: '#ffecec', label: '紧急', key: '2' },
				// { color: '#fa6400', bgColor: '#ffecdf', label: '紧急', key: '2', },
				{ color: '#F7B500', bgColor: '#fff7e1', label: '一般', key: '3' },
				// { color: '#0091FF', bgColor: '#dcf0ff', label: '较低', key: '4', },
			],
			// 任务类型标签
			btnBoxLists: [
				{ color: '#0091FF', bgColor: '#dcf0ff', label: '内部整改', key: '1' },
				{ color: '#F7B500', bgColor: '#fff7e1', label: '客户报障', key: '2' },
			],
			// 电梯状态
			eleStateLists: [
				{ color: '#0091FF', bgColor: '#dcf0ff', label: '运行中', key: '1' },
				{ color: '#F7B500', bgColor: '#fff7e1', label: '停梯', key: '2' },
			],
			addressObj: {
				userName: '',
				phone: '',
				address: '',
				pcAaddress: '',
			},
			// 复制对象
			objDataCopy: {},

			imgUrls: [],
			showSubmit: true,
			// 备注内容
			remarksContent: '',
			// 提交按钮状态
			btnStatus: false,
			// 自定义配件状态
			showCustom: false,
			// 自定义数据
			customArrs: [],
			// 配件数据
			partsSelectArr: [],
			userData: hanleToken('get', 'userData'),
			// 组长信息
			groupObj: {},
			// 弹框状态
			visibleShow: false,
			// 编辑id
			planIdEdit: null,
			// 是否独立申请配件
			independent: true,
			// 电梯信息
			elevtorInfo: {
				buildingName: '',
				buildingAddress: '',
				elevatorAddress: '',
				nameAttachmentList: [],
				disabled: false,

			},
			// 判断从哪里条件来 apply我的申请
			fromType: 'apply',

			statusActive: -1,
			visible: false,
			maskCloseAble: true,
			defaultValue: '442000004',
			column: 3,
			showTips: true,
			editAddobj: {},
			// 展示任务类型
			workShow: true,
			// 自定义配件名称
			other: '',
			// 是否退回状态
			isReturn: '',
			// 退回原因
			returnMsg: '',
			// 0.项目地址 1.公司地址
			tabIndex: 0,
			// 是否编辑地址
			isEditAddress: false,
			// 选择配件类型当前索引
			partsIndex: 0,
			itemList: [
				{
					// 自定义配件名称
					other: '',
					// 配件id
					partsId: '',
					// 配件名称
					partsName: '',
					// 自定义配件状态
					showCustom: false,
					// 自定义名字
					name: '',
					// 型号
					partsModel: '',
					// 电梯配件数量
					num: 1,
					// 计量单位,
					unitNameValue: '',
					desc: '',
					otherUrl: [],
					templateList: [],
					// 部件关联的类目id
					categoryId: '',
					// categoryInfo: '',
					// 部件关联的skuId
					skuId: '',
					skuName: '',
					skuList: [],
					isMore: true,
					isDefault: false,
					floorStandIds: null,
					floorStandNames: null,
					// uitde id
					unitValue:''
				},
			],
			pickData: {
				index: 0,
				prop: null,
				value: [],
				list: [],
				orgList: [],
				isSearch: true,
				searchPlaceholder: '请输入关键字搜索',
				title: '选择配件',
			},
			currentUnitIndex: null, // 新增：当前操作的配件索引
			elevatorData: [] // 电梯数据
		};
	},
	async onLoad(opt) {
		this.handleRreshToken();
		this.planIdEdit = opt.planIdEdit || '';
		this.independent = opt.independent || false;
		this.fromType = opt.fromType || 'apply';
		this.isReturn = opt.isReturn || 2;
		this.returnMsg = opt.returnMsg || '';
		// 配件弹窗指示提示
		if (hanleToken('get', 'partsTipsStatus') || this.planIdEdit) {
			this.showTips = false;
		}
		// await this.elevtorDetail(opt.id);
		// 维修详情页添加配件记录
		if (opt.malWorksId && opt.fromPlanId) {
			this.fromType = 'tasksPage';
			let objData = hanleToken('get', 'partsUpObj');
			this.editAddobj = Object.assign({}, objData);
			this.objData = objData;
			// 维修添加部件id
			this.objData.malWorksId = opt.malWorksId || '';
			// 维修添加配件工单id
			this.objData.fromPlanId = opt.fromPlanId || '';
			// 维修添加配件工单id
			this.objData.wxPlanId = opt.fromPlanId || '';
			this.imgUrls = objData.imgUrls;

			this.objData.num = 1;
			let strs = objData.partsName || '';
			this.objData.partsName = this.resStr(strs.replace(/&amp;&amp;/g, ' > '));
			if (opt.floorStandIds === 'null') {
				opt.floorStandIds = '';
			}
			this.objData.floorStandIds = opt.floorStandIds;
			this.objData.floorStandNames = opt.floorStandNames;
			this.itemList[0].floorStandIds = opt.floorStandIds;
			this.itemList[0].floorStandNames = opt.floorStandNames;
			if (objData.imgUrls) {
				this.itemList[0].otherUrl = objData.imgUrls;
			}
			if (objData.partsId) {
				let arr = (objData.partsId || '').split(',');
				if (arr.length) {
					this.objData.malPartId = arr[arr.length - 1];
				}
			}

			for (const key in this.objData) {
				if (this.itemList[0].hasOwnProperty(key)) {
					this.itemList[0][key] = this.objData[key];
				}
			}
		}
		if (this.planIdEdit) {
			await partsMyAuditDetail({ planId: this.planIdEdit }).then(async (res) => {
				console.log(res.data,'看看详情');
				if (res.code === 200) {
					if (Object.keys(res.data).length > 0) {
						if (
							res.data.skuPartsInfo &&
              !Array.isArray(res.data.skuPartsInfo) &&
              res.data.skuPartsInfo.skuItemList
						) {
							res.data.skuPartsInfo = res.data.skuPartsInfo.skuItemList;
						} else {
							res.data.skuPartsInfo = [];
						}
						this.objData = res.data || {};
						// 获取电梯信息
						// await this.elevtorDetail();
						this.editAddobj = Object.assign({}, this.objData);
						if (!this.objData.partsList || this.objData.partsList.length === 0) {
							let str = res.data.partsName || '';
							let arr1 = (res.data.partsId || '').split(',');
							let arr2 = str.split('&amp;&amp;');
							this.objData.partsName = this.resStr(
								str.replace(/&amp;&amp;/g, ' > ')
							);
							if (arr2.length > arr1.length) {
								this.showCustom = true;
								this.itemList[0].showCustom = true;
								this.objData.name = arr2[arr2.length - 1];
								this.objData.partsName = this.objData.partsName.substring(
									0,
									this.objData.partsName.lastIndexOf(' > ')
								);
							}
						}
						let str = res.data.partsName || '';
						let arr1 = (res.data.partsId || '').split(',');
						let arr2 = str.split('&amp;&amp;');
						this.objData.partsName = this.resStr(
							str.replace(/&amp;&amp;/g, ' > ')
						);
						if (arr2.length > arr1.length) {
							this.showCustom = true;
							this.itemList[0].showCustom = true;
							this.objData.name = arr2[arr2.length - 1];
							this.objData.partsName = this.objData.partsName.substring(
								0,
								this.objData.partsName.lastIndexOf(' > ')
							);
						}
						if (res.data.partAddress) {
							this.addressObj = { ...res.data.partAddress };
							this.addressObj.pcAaddress =
                res.data.partAddress.provinceName +
                res.data.partAddress.cityName +
                res.data.partAddress.adName;
							delete this.addressObj.isDeleted;
							delete this.addressObj.status;
							if (this.addressObj.adCode) {
								this.defaultValue = this.addressObj.adCode;
							}
							if (this.addressObj.buildingId) {
								this.addressObj.locationAddress = this.addressObj.address;
								this.tabIndex = 0;
								this.statusActive = 1;
							} else {
								this.tabIndex = 1;
								this.statusActive = 0;
							}
						}
						if (res.data.otherUrl) {
							this.imgUrls = res.data.otherUrl;
						}
						if (res.data.approveId) {
							this.objData.approveId = res.data.approveId;
						}
						// 退回图片
						if (res.data.imgs && res.data.imgs.length) {
							this.returnImgUrls = res.data.imgs.map((item) => {
								return item.url;
							});
						}
						if (this.objData.partsList && this.objData.partsList.length > 0) {
							let obj = {
								...this.itemList[0]
							};
							this.objData.partsList.forEach((item, i)=>{
								let str = item.partsName || '';
								let arr1 = (item.partsId || '').split(',');
								let arr2 = str.split('&amp;&amp;');
								item.partsName = this.resStr(
									str.replace(/&amp;&amp;/g, ' > ')
								);
								if (arr2.length > arr1.length) {
									this.showCustom = true;
									this.itemList[i].showCustom = true;
									item.name = arr2[arr2.length - 1];
									item.partsName = item.partsName.substring(
										0,
										item.partsName.lastIndexOf(' > ')
									);
								}
								if (
									item.skuPartsInfo &&
                    !Array.isArray(item.skuPartsInfo) &&
                    item.skuPartsInfo.skuItemList
								) {
									item.skuPartsInfo = item.skuPartsInfo.skuItemList;
								} else {
									item.skuPartsInfo = [];
								}
								if (i > 0) {
									this.itemList[i] = {...obj};
								}
								this.itemList[i].id = item.id;
								console.log(item, 'partsList', i);
								if (item.categoryId) {
									this.getSkuTemplate(item.categoryId, i, item.skuId);
								}
								for (const key in item) {
									if (this.itemList[i].hasOwnProperty(key)) {
										this.itemList[i][key] = item[key];
									}
								}
							});
							console.log(this.itemList, 'this.itemList');
						} else {
							for (const key in this.objData) {
								if (this.itemList[0].hasOwnProperty(key)) {
									this.itemList[0][key] = this.objData[key];
								}
							}
							if (res.data.otherUrl) {
								this.itemList[0].otherUrl = res.data.otherUrl;
							}
							if (res.data.categoryId) {
								await this.getSkuTemplate(res.data.categoryId, 0, res.data.skuId);
							}
						}

						// 这里判断下这里是修改
						// 			if (
						// 				res.data.elevatorAttachmentHistory &&
						//   res.data.maintainPlanContentExt
						// 			) {
						// 				if (res.data.elevatorAttachmentHistory.attachment == null) {
						// 					this.editMingObj.elevatorNameAttachment = JSON.parse(
						// 						res.data.maintainPlanContentExt.elevatorNameAttachment
						// 					);
						// 				} else {
						// 					this.editMingObj.elevatorNameAttachment = JSON.parse(
						// 						res.data.elevatorAttachmentHistory.attachment
						// 					);
						// 				}
						// 			}
					}
				}
			});
		} else {
			// 如果是新增
			// await this.elevtorDetail();
		}
		if (opt.workOrderType && opt.emerProcType) {
			this.objData.workOrderType = opt.workOrderType || 2;
			this.objData.emerProcType = opt.emerProcType;
			this.workShow = false;
			if (this.objData.workOrderType === 1) {
				this.objData.planTypeDesc = opt.planTypeDesc
					? `内部整改-${opt.planTypeDesc}`
					: '内部整改';
			}
		}
		uni.setNavigationBarTitle({
			title: this.planIdEdit ? '修改申请配件' : '申请配件',
		});
		if (opt.obj) {
			let obj = JSON.parse(opt.obj);
			this.objData.elevatorId = obj.elevatorId;
			this.objData.fromPlanId = obj.planId;
		} else if (opt.multiElevators) {
			let elevatorData = uni.getStorageSync('elevatorData') || [];
			if (elevatorData.length > 1) {
				this.elevatorData = elevatorData;
			}
			console.log(elevatorData,'elevatorData');
			this.objData.elevatorId = elevatorData.length > 0 && elevatorData[0].elevatorId;
		} else {
			this.objData.elevatorId = opt.id;
		}
		if (this.itemList[0].categoryId && opt.malWorksId && opt.fromPlanId) {
			await this.getSkuList(this.itemList[0], 0);
			await this.getSkuOptions(this.itemList[0], 0);
			this.getSkuTemplate(this.itemList[0].categoryId, 0);
		}
		// #ifndef H5
		uni.$on('part-selectd', (res) => {
			// console.log(`part-selectd receive:${JSON.stringify(res)}`);
			console.log('part-selectd receive:', res);
			this.partsSubmit(res);
		});
		// #endif
		// await this.elevtorDetail();
		// #ifdef H5
		setTimeout(() => {
			uni.$on('part-selectd', (res) => {
				console.log(`part-selectd receive:${JSON.stringify(res)}`);
				this.partsSubmit(res);
			});
		}, 1000);
		// #endif
		await this.elevtorDetail();
		this.initGetUserInfos();
		if (!this.planIdEdit) {
			this.getCompanyAddress(2, 2);
		}
	},
	onUnload() {
		hanleToken('remove', 'partsUpObj');
		uni.$off('part-selectd');
	},
	computed: {
		...mapState('user', ['userinfo']),
		showArrow() {
			if (this.returnImgUrls && this.returnImgUrls.length) {
				return true;
			}
			if (this.returnMsg.length > 20) {
				return true;
			} else {
				return false;
			}
		},
	},
	methods: {
		// 非其他提交
		submitUnit(res) {
			this.$refs.unitPopup.close();

			if (this.currentUnitIndex !== null) {
				this.itemList[this.currentUnitIndex].unitNameValue = res.label;
				this.itemList[this.currentUnitIndex].unitValue = res.value;
			}
			console.log(this.currentUnitIndex,res,'点击提交');
		},
		...mapActions('user', ['handleRreshToken']),
		handlePopupChange() {},
		changeNameTemlate(res) {
			console.log(res, 22222);
			this.nameplateList = res;
		},

		// 指引图片
		handleClickImg(form, i) {
			console.log(form, i);
			this.$refs.popupImg.open();
			this.showImg = true;
			this.$nextTick(() => {
				this.$refs.imgDialog.setActive(form.key);
			});

			// this.$refs.pickPopup.open();
		},
		closeImg() {
			this.$refs.popupImg.close();
			this.showImg = false;
		},
		// 选择紧急程度和任务类型
		selectBtn(val, key) {
			if (key === 'workOrderType' && this.planIdEdit) {
				return;
			}
			this.objData[key] = val;
			this.$forceUpdate();
		},
		// 获取电梯详情
		elevtorDetail() {
			console.log(this.planIdEdit, 'this.planIdEdit');
			return new Promise((reslove) => {
				elevtorDetail({ elevatorId: this.objData.elevatorId }).then((res) => {
					if (res) {
						this.elevtorInfo = res.data;
						if (this.elevatorData.length > 0) {
							this.elevtorInfo.elevatorAddress = this.elevatorData.map(v=>v.elevatorAddress).join('、');
						}
						// 如果是新增
						if (!this.planIdEdit) {
							if (this.elevtorInfo.nameAttachmentList.length && this.elevtorInfo.nameAttachmentList[0].attachment !== null && this.elevtorInfo.nameAttachmentList[0].attachment !== 'null') {
								this.elevtorInfo.disabled = true;
								this.nameplateList[0] = JSON.parse(
									this.elevtorInfo.nameAttachmentList[0].attachment
								).url;
								console.log(this.nameplateList, '11111');
							}
						} else {
							console.log(888, this.objData);
							// 这里拿到objdata得值
							let {
								elevatorAttachmentHistory: { attachment },
								maintainPlanContentExt: { elevatorNameAttachment },
							} = this.objData;
							console.log(attachment, elevatorNameAttachment, '铭牌');
							if (attachment == null) {
								// 如果在扩展表就还是可以编辑
								this.elevtorInfo.disabled = false;
								if (JSON.parse(elevatorNameAttachment)) {
									this.nameplateList[0] = JSON.parse(elevatorNameAttachment).url;
								}
							} else {
								this.elevtorInfo.disabled = true;
								if (JSON.parse(attachment)) {
									this.nameplateList[0] = JSON.parse(attachment).url;
								}
							}
							// let arr=
						}

						reslove();
					}
				});
			});
		},
		initGetUserInfos() {
			getApproveUserData({ submitId: this.userData.user_id }).then((res) => {
				if (res.code === 200) {
					this.groupObj = res.data;
					console.log(res.data, 99999);
				}
			});
		},
		// 获取公司地址
		getCompanyAddress(type = 1, cur = 1, planIdEdit = 0) {
			var result = null;
			if (type === 1) {
				result = partsCompanyAddress({ planId: planIdEdit });
				this.addressObj.buildingId = 0;
			}
			if (type === 2) {
				result = getBuilding(this.elevtorInfo.buildingId);
				this.addressObj.buildingId = this.elevtorInfo.buildingId;
			}
			result.then((res) => {
				if (res.code === 200) {
					let objs = res.data || {};
					// eslint-disable-next-line no-unused-vars
					let {
						userName,
						phone,
						provinceName,
						adCode,
						cityCode,
						provinceCode,
						cityName,
						adName,
						locationAddress,
						address,
						id,
					} = objs;
					this.addressObj.userName =
            userName || (objs.buildingContacts || {}).contactsName;
					this.addressObj.phone = phone || (objs.buildingContacts || {}).phone;
					this.addressObj.pcAaddress = provinceName + cityName + adName;
					this.addressObj.address = address;
					this.addressObj.adCode = adCode;
					this.addressObj.adName = adName;
					this.addressObj.cityCode = cityCode;
					this.addressObj.cityName = cityName;
					this.addressObj.provinceCode = provinceCode;
					this.addressObj.provinceName = provinceName;
					if (type === 1) {
						this.addressObj.locationAddress = objs.locationAddress;
					} else {
						this.addressObj.locationAddress = objs.address;
						this.addressObj.userName = this.userinfo.nick_name;
						this.addressObj.phone = this.userinfo.phone;
					}
					if (this.planIdEdit && type === 1 && cur === 1) {
						this.addressObj.id = id;
					}
					if (adCode) {
						this.defaultValue = adCode;
					}
					if (
						type === 1 &&
            cur === 1 &&
            objs.buildingId == this.elevtorInfo.buildingId
					) {
						this.statusActive = 1;
						// this.getCompanyAddress(2)
					}
				}
			});
		},
		changeStatus(index) {
			this.statusActive = index;
			let type = index + 1;
			if (this.planIdEdit) {
				if (
					type === 1 &&
          this.objData.partAddress &&
          (!this.objData.partAddress.buildingId ||
            this.objData.partAddress.buildingId === -1)
				) {
					this.addressObj = { ...this.objData.partAddress };
					this.addressObj.pcAaddress =
            this.objData.partAddress.provinceName +
            this.objData.partAddress.cityName +
            this.objData.partAddress.adName;
					delete this.addressObj.isDeleted;
					delete this.addressObj.status;
					if (this.addressObj.adCode) {
						this.defaultValue = this.addressObj.adCode;
					}
				} else if (
					type === 2 &&
          this.objData.partAddress &&
          this.objData.partAddress.buildingId == this.elevtorInfo.buildingId
				) {
					this.addressObj = { ...this.objData.partAddress };
					this.addressObj.pcAaddress =
            this.objData.partAddress.provinceName +
            this.objData.partAddress.cityName +
            this.objData.partAddress.adName;
					delete this.addressObj.isDeleted;
					delete this.addressObj.status;
					if (this.addressObj.adCode) {
						this.defaultValue = this.addressObj.adCode;
					}
					this.addressObj.locationAddress = this.addressObj.address;
				} else {
					this.getCompanyAddress(type, 2);
				}
			} else {
				this.getCompanyAddress(type, 2);
			}
		},
		openCity() {
			this.$nextTick((_) => {
				this.$refs.cityPicker.init();
				this.visible = true;
			});
		},
		confirmCity(val = {}) {
			console.log(val);
			this.addressObj.adCode = val.code;
			this.addressObj.adName = val.areaName;
			this.addressObj.cityCode = val.cityCode;
			this.addressObj.cityName = val.cityName;
			this.addressObj.provinceCode = val.provinceCode;
			this.addressObj.provinceName = val.provinceName;
			this.addressObj.pcAaddress = val.name;
			this.visible = false;
		},
		cancelCity() {
			this.visible = false;
		},
		// 选择配件
		selectPartsClick(item, index) {
			if (
				this.planIdEdit &&
        this.objData.malDetailVO.planId &&
        this.objData.fromPlanId
			)
				return;
			if (this.objData.disabled) return;
			this.partsIndex = index;
			console.log(this.partsIndex, 'this.partsIndex');
			uni.navigateTo({
				url: `/pages/pubilc/partSelect?elevatorId=${this.objData.elevatorId}&formPage=applyParts`,
				fail: (fail) => {
					console.log(fail);
				},
			});
		},

		closed() {
			this.showTips = false;
		},

		resStr(str, num = 25) {
			return str && str.length > num ? str.substring(0, num) + '...' : str;
		},
		// 电梯配件数量
		changeNumber() {
			console.log('changeNumber', this.objData.num);
		},

		// 配件搜索选择确定
		partsSubmit(res) {
			console.log(this.partsIndex, 'this.partsIndex-partsSubmit');
			let names = res.names;
			let ids = res.ids;
			let item = res.checkedItem;
			console.log(item, 'item');
			if (res.flag && res.flag.id) {
				this.itemList[this.partsIndex].floorStandIds = res.flag.ids.join(',');
				this.itemList[this.partsIndex].floorStandNames =
          res.flag.names.join(',');
				this.objData.floorStandIds = res.flag.ids.join(',');
				this.objData.floorStandNames = res.flag.names.join(',');
			} else {
				delete this.itemList[this.partsIndex].floorStandIds;
				delete this.itemList[this.partsIndex].floorStandNames;
			}
			// 设置配件sku选项
			let options = [];
			if (item.skuIds && item.skuInfos) {
				let skuIds = item.skuIds.split(',');
				let skuInfos = item.skuInfos.split(',');
				skuIds.forEach((v, i) => {
					options.push({
						label: item.name,
						value: v,
						desc: skuInfos[i].replaceAll('/', ';'),
					});
				});
			}
			console.log(options, 'options');
			// this.partsSelectArr = ids;
			// this.other = res.other || '';
			this.itemList[this.partsIndex].other = res.other || '';
			this.itemList[this.partsIndex].partsModel = '';
			this.itemList[this.partsIndex].partsId = ids;
			this.itemList[this.partsIndex].skuId = null;
			this.itemList[this.partsIndex].skuName = null;
			this.itemList[this.partsIndex].spuName = '';
			this.itemList[this.partsIndex].categoryId = null;
			this.itemList[this.partsIndex].skuList = [];
			this.itemList[this.partsIndex].templateList = [];
			this.itemList[this.partsIndex].otherUrl = [];
			this.itemList[this.partsIndex].isDefault = false;
			if (options.length) {
				this.itemList[this.partsIndex].skuList = options;
			}
			if (item.categoryId) {
				this.itemList[this.partsIndex].categoryId = item.categoryId;
				// this.itemList[this.partsIndex].categoryInfo = item.categoryInfo || '';
				this.objData.skuPartsInfo = [];
				this.getSkuTemplate(item.categoryId, this.partsIndex);
				// this.getSkuOptions(this.itemList[this.partsIndex], this.partsIndex);
			}
			if (item.categoryId && !options.length) {
				this.itemList[this.partsIndex].isDefault = true;
			}
			this.pickData.value = [];
			this.itemList[this.partsIndex].partsName = names.join('>');
		},
		// 图片上传
		changeImg(imgArr = []) {
			this.imgUrls = imgArr;
			this.tipsState = false;
		},
		// 图片上传
		handleChangeImg(imgArr = [], item) {
			item.otherUrl = imgArr;
			this.tipsState = false;
		},
		cancle() {
			this.visibleShow = false;
		},
		// 确定提交工单
		comfire() {
			uni.showLoading({
				title: '提交中',
				mask: true,
			});
			let objs = {};
			if (this.planIdEdit || this.isReturn == 1) {
				// 配件信息编辑
				// let { partsId, partsName, partsModel, num, desc, planId, otherUrl, elevatorId, emerProcType,floorStandNames,floorStandIds } =
				//   this.objDataCopy;
				let {
					elevatorId,
					emerProcType,
					floorStandNames,
					floorStandIds,
					partsList,
					elevatorStop,
					approveId,
				} = this.objDataCopy;
				// objs = { partsId, partsName, partsModel, num, desc, planId, otherUrl, planFrom: 5, elevatorId, emerProcType,floorStandNames,floorStandIds };
				objs = {
					approveId,
					planFrom: 5,
					elevatorId,
					emerProcType,
					floorStandNames,
					floorStandIds,
					partsList,
					elevatorStop,
				};
				// if (partsName) {
				// 	objs.partsName = objs.partsName.split('>').join('&&');
				// }
				this.addressObj.planId = this.planIdEdit;
				objs.partAddress = this.addressObj;
				objs.planId = this.planIdEdit;
				if (!elevatorStop) {
					delete this.objDataCopy.elevatorStop;
					delete objs.elevatorStop;
				}
			} else if (this.elevatorData) {
				objs.elevatorIds = this.elevatorData.map(v => v.elevatorId).join(',');
				delete objs.elevatorId;
			}
			if (this.objDataCopy.malPartId) {
				objs.malPartId = this.objDataCopy.malPartId;
			}
			if (this.objDataCopy.malWorksId) {
				objs.malWorksId = this.objDataCopy.malWorksId;
			}
			// 铭牌
			if (this.nameplateList.length) {
				this.objDataCopy.nameAttachment = {
					type: 'image',
					url: this.nameplateList[0],
				};
				objs.nameAttachment = { type: 'image', url: this.nameplateList[0] };
			}
			// return;
			// this.objDataCopy.partsName = this.objDataCopy.partsName.split('>').join('&&');
			console.log(objs, this.objDataCopy, '看看参数');
			// 如果是独立新增的配件任务不需要传fromPlanId
			// eslint-disable-next-line no-unused-vars
			let { fromPlanId, wxPlanId, ...independentObjDataCopy } =
        this.objDataCopy;
			let planIdDetils;
			let request = null;
			if (this.isReturn == 1) {
				request = partsResubmit(objs);
			} else if (this.planIdEdit) {
				request = partsMyAuditDetailWork(objs);
			} else {
				request = partsStart(
					this.independent
						? { ...independentObjDataCopy, planFrom: 5 }
						: { ...this.objDataCopy, planFrom: 5 }
				);
			}
			request.then((res) => {
				if (res.code === 200) {
					if (res.data) {
						// 配件详情id
						planIdDetils = res.data;
					}
					if (this.planIdEdit) {
						// 配件详情id
						planIdDetils = this.objDataCopy.planId;
					}
					if (this.other) {
						let partsIds = [...this.objData.partsId];
						this.addCustompartslog({
							partId: partsIds[partsIds.length - 1],
							other: this.other,
							planId: planIdDetils,
							fromLocation: 'pageModules/parts/applyParts',
						});
					}
					uni.hideLoading();
					uni.showToast({
						title: '提交成功',
						icon: 'none',
					});
					this.showCustom = false;
					this.itemList[0].showCustom = false;
					this.objData = {
						elevatorId: '',
						// // 配件id
						// partsId: '',
						// // 配件名称
						// partsName: '',
						// // 自定义
						// name: '',
						// // 型号
						// partsModel: '',
						// // 电梯配件数量
						// num: 1,
						// desc: '',
						// otherUrl: [],
						approveId: '',
						fromPlanId: '',
						malPartId: '',
						emerProcType: '',
						wxPlanId: '',
					};
					this.itemList = [
						{
							// 自定义配件名称
							other: '',
							// 配件id
							partsId: '',
							// 配件名称
							partsName: '',
							// 自定义配件状态
							showCustom: false,
							// 自定义名字
							name: '',
							// 型号
							partsModel: '',
							// 电梯配件数量
							num: 1,
							// 计量单位
							unitNameValue: '',
							desc: '',
							otherUrl: [],
							templateList: [],
							// 部件关联的类目id
							categoryId: '',
							// categoryInfo: '',
							// 部件关联的skuId
							skuId: '',
							skuName: '',
							spuName: '',
							skuList: [],
							isMore: true,
							isDefault: false,
							malDetailVO: null,
							floorStandIds: null,
							floorStandNames: null,

							unitValue:''
						},
					];
					uni.removeStorageSync('elevatorData');
					// 判断是从我的申请还是申请记录跳转过来
					if (planIdDetils) {
						uni.redirectTo({
							url: `/subpages/approve/partApprovalDetail?type=3&&id=${planIdDetils}&fromType=${this.fromType}&fromPlanId=${this.objDataCopy.fromPlanId}`,
						});
					} else {
						uni.redirectTo({
							url: '/pageModules/myApplication/myApplication?type=1',
						});
					}
				}
			});
		},
		// 点击申请按钮
		submitClicksr() {
			let obj = Object.assign({}, this.objData, {
				partAddress: this.addressObj,
			});
			// eslint-disable-next-line no-unused-vars
			const {
				name,
				desc,
				num,
				partsModel,
				partsName,
				workOrderType,
				emerProcType,
				elevatorStop,
			} = obj;
			let str = '';
			console.log(this.addressObj, 'addressObj');
			[
				'createDept',
				'createTime',
				'createUser',
				'updateTime',
				'updateUser',
			].forEach((key) => {
				delete this.addressObj[key];
			});
			console.log(this.addressObj, 'addressObj');
			let pStatus = Object.values(this.addressObj).every(
				(item) => item || item === 0
			);
			console.log(pStatus, 'pStatus');
			console.log(Object.values(this.addressObj), 'pStatus');
			if (this.elevatorData.length < 2) {
				if (
					!this.nameplateList.length &&
            !this.elevtorInfo.nameAttachmentList.length
				) {
					str = '请上传铭牌';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
			}

			if (!workOrderType) {
				str = '请选择任务类型';
				uni.showToast({
					title: str,
					icon: 'none',
				});
				return;
			}
			if (!emerProcType) {
				str = '请选择紧急程度';
				uni.showToast({
					title: str,
					icon: 'none',
				});
				return;
			}
			if (!elevatorStop && !this.objData.fromPlanId) {
				str = '请选择电梯状态';
				uni.showToast({
					title: str,
					icon: 'none',
				});
				return;
			}
			let partsList = [];
			let arr = JSON.parse(JSON.stringify(this.itemList));
			for (let i = 0; i < arr.length; i++) {
				let item = arr[i];
				console.log(item, 'itemList');
				if (!item.partsName) {
					str = `配件明细-${i + 1}:` + '请选择电梯配件';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
				// if (item.categoryId && !item.skuId && item.skuList.length) {
				// 	str = `配件明细-${i + 1}:` +  '请选择配件';
				// 	uni.showToast({
				// 		title: str,
				// 		icon: 'none',
				// 	});
				// 	return;
				// }
				if (
					(!item.categoryId ||
            ((!item.skuList || item.skuList.length === 0) &&
              item.templateList.length === 0)) &&
          !item.partsModel
				) {
					str = `配件明细-${i + 1}:` + '请选择电梯配件规格/型号';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				} else {
					// 匹配这些中文标点符号 。 ？ ！ ， 、 ； ： “ ” ‘ ' （ ） 《 》 〈 〉 【 】 『 』 「 」 ﹃ ﹄ 〔 〕 … — ～ ﹏ ￥
					let reg =
            /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\u2013|\uff5e|\ufe4f|\uffe5|\uff0e]/;
					if (reg.test(partsModel)) {
						str = `配件明细-${i + 1}:` + '配件型号请按照填写示例进行录入';
						uni.showToast({
							title: str,
							icon: 'none',
						});
						return;
					}
				}
				if (!item.otherUrl.length) {
					str = `配件明细-${i + 1}:` + '请上传照片/视频';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
				if (!item.num) {
					str = `配件明细-${i + 1}:` + '请选择配件数量';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
				if (!item.unitNameValue) {
					str = `配件明细-${i + 1}:` + '请选择配件单位';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
				if (!item.name && item.showCustom) {
					str = `配件明细-${i + 1}:` + '请输入自定义配件';
					uni.showToast({
						title: str,
						icon: 'none',
					});
					return;
				}
				let skuPartsInfo = [];
				if (item.categoryId && item.skuId && item.spuName) {
					skuPartsInfo.push({
						label: '配件名称',
						attrName: '配件名称',
						attrValues: item.spuName,
						value: item.spuName,
						categoryId: item.categoryId,
						spuName: item.spuName,
						skuId: item.skuId,
					});
				}
				if (item.templateList && item.templateList.length) {
					for (const row of item.templateList) {
						if (!item.skuId && row.required && !row.value) {
							str = `配件明细-${i + 1}:` + '请输入' + row.label;
							uni.showToast({
								title: str,
								icon: 'none',
							});
							return;
						}
						if (row.value) {
							skuPartsInfo.push({
								id: row.key,
								label: row.label,
								value: row.value,
								skuId: item.skuId,
								...row.obj,
								// unitName: row.unitName,
								// unitCnName: row.unitCnName,
							});
						}
					}
				}
				if (item.partsId.length > 0 && Array.isArray(item.partsId)) {
					item.partsId = item.partsId.join(',');
				}
				if (item.partsName) {
					item.partsName = item.partsName.split('>').join('&&');
				}
				if (!item.floorStandIds) {
					delete item.floorStandIds;
				}
				if (!item.floorStandNames) {
					delete item.floorStandNames;
				}
				if (item.categoryId) {
					item.skuPartsInfo = {
						attr: '',
						brandName: '',
						categoryId: '',
						keyAttr: null,
						picture: '',
						skuCode: '',
						skuId: '',
						spuId: '',
						spuName: '',
					};
				} else {
					item.skuPartsInfo = null;
				}
				if (item.skuId) {
					const skuItem = item.skuList.find((v) => v.skuId === item.skuId);
					console.log(skuItem, 'skuItem');
					if (skuItem) {
						item.skuPartsInfo = {
							...skuItem,
						};
					}
				}
				if (skuPartsInfo.length && item.skuPartsInfo) {
					// item.skuPartsInfo = JSON.stringify(skuPartsInfo);
					item.skuPartsInfo.skuItemList = skuPartsInfo;
				}
				console.log(item.skuPartsInfo, 'skuPartsInfo');
				console.log(JSON.stringify(item.skuPartsInfo), 'skuPartsInfo');
				delete item.templateList;
				partsList.push({
					...item,
				});
			}
			obj.partsList = partsList;
			//
			// if (!partsModel) {
			// str = '请选择电梯配件规格/型号';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// } else {
			// // 匹配这些中文标点符号 。 ？ ！ ， 、 ； ： “ ” ‘ ' （ ） 《 》 〈 〉 【 】 『 』 「 」 ﹃ ﹄ 〔 〕 … — ～ ﹏ ￥
			// var reg = /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\u2013|\uff5e|\ufe4f|\uffe5|\uff0e]/;
			// if (reg.test(partsModel)) {
			// str = '配件型号请按照填写示例进行录入';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// }
			// }
			// if (!partsName) {
			// str = '请选择电梯配件';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// }
			// if (!this.imgUrls.length) {
			// str = '请上传照片/视频';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// }
			// if (!num) {
			// str = '请选择配件数量';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// }
			// if (!name && this.showCustom) {
			// str = '请输入自定义配件';
			// uni.showToast({
			// title: str,
			// icon: 'none',
			// });
			// return;
			// }
			//     *
			// if (!pStatus) {
			// 	uni.showToast({
			// 		title: '请输入收货地址',
			// 		icon: 'none',
			// 	});
			// 	return;
			// }
			if (!obj.partAddress.userName) {
				uni.showToast({
					title: '请输入收货人',
					icon: 'none',
				});
				return;
			}
			function validatePhoneNumber(phone) {
				if (!phone) {
					return false;
				}
				const regex400 = /^400(-\d{3}){2}\d{1}$/; // 400电话
				const regexMobile = /^1[3-9]\d{9}$/; // 手机号
				const regexLandline = /^(0\d{2,3}-?)?\d{7,8}$/; // 固话号码
				return (
					regex400.test(phone) ||
          regexMobile.test(phone) ||
          regexLandline.test(phone)
				);
			}
			console.log(
				validatePhoneNumber(obj.partAddress.phone),
				'this.validatePhoneNumber(obj.partAddress.phone)'
			);
			// if (this.statusActive >= 0) {
			if (!validatePhoneNumber(obj.partAddress.phone)) {
				uni.showToast({
					title: '请输入正确手机号或固定号码',
					icon: 'none',
				});
				return;
			}
			if (!obj.partAddress.pcAaddress) {
				uni.showToast({
					title: '请输入所在地区',
					icon: 'none',
				});
				return;
			}
			if (!obj.partAddress.address) {
				uni.showToast({
					title: '请输入详细地址',
					icon: 'none',
				});
				return;
			}
			// }
			// if (this.imgUrls.length > 0) {
			// 	obj.otherUrl = this.imgUrls;
			// }
			// if (this.partsSelectArr.length > 0) {
			// 	obj.partsId = this.partsSelectArr.join(',');
			// }
			// if (obj.partsId.length > 0) {
			// 	obj.partsId = obj.partsId.join(',');
			// }
			this.visibleShow = true;
			obj.id = this.objData.malPartId;
			if (this.objData.malPartId) {
				obj.malPartId = this.objData.malPartId;
			}
			if (this.objData.malWorksId) {
				obj.malWorksId = this.objData.malWorksId;
			}
			if (this.elevatorData.length > 0) {
				obj.elevatorIds = this.elevatorData.map(item => item.elevatorId);
			} else {
				obj.elevatorIds = [this.objData.elevatorId];
			}
			// 铭牌
			this.objDataCopy = Object.assign({}, obj);
			console.log(this.objDataCopy, 'objDataCopy');
		},
		// 点击标签
		handleTabClick(index) {
			this.tabIndex = index;
			this.changeStatus(index === 1 ? 0 : 1);
		},
		// 展开收起
		handleExpanded(item, index) {
			item.isMore = !item.isMore;
		},
		// 点击添加配件
		handleClickAdd() {
			let obj = {
				// 自定义配件名称
				other: '',
				// 配件id
				partsId: '',
				// 配件名称
				partsName: '',
				// 自定义配件状态
				showCustom: false,
				// 自定义名字
				name: '',
				// 型号
				partsModel: '',
				// 电梯配件数量
				num: 1,
				// 计量单位
				unitNameValue: '',
				desc: '',
				otherUrl: [],
				templateList: [],
				// 部件关联的类目id
				categoryId: '',
				// categoryInfo: '',
				// 部件关联的skuId
				skuId: '',
				skuName: '',
				spuName: '',
				skuList: [],
				isMore: true,
				isDefault: false,
				floorStandIds: null,
				floorStandNames: null,
				unitValue:''
			};
			if (this.objData.fromPlanId) {
				for (const key in obj) {
					if (this.itemList[0].hasOwnProperty(key)) {
						obj[key] = this.itemList[0][key];
					}
				}
				let obj2 = {
					partsModel: '',
					num: 1,
					unitNameValue: '',
					unitValue:'',
					desc: '',
					otherUrl: [],
					// 部件关联的skuId
					skuId: '',
					skuName: '',
					spuName: '',
					isMore: true,
				};
				obj = { ...obj, ...obj2 };
			}
			this.itemList.push(obj);
		},
		// 删除
		handleDel(item, index) {
			if (this.itemList.length === 1) return;
			this.itemList.splice(index, 1);
		},
		// 点击选择配件规格
		handleClickSku(item, index) {
			if (!item.skuList || item.skuList.length === 0) return;
			this.pickData = {
				index: index,
				prop: 'skuId',
				value: item.skuId ? [item.skuId] : [],
				list: [...item.skuList],
				orgList: [...item.skuList],
				isSearch: true,
				searchPlaceholder: '请输入关键字搜索',
				title: '选择配件',
			};
			this.$refs.pickPopup.open();
		},
		handlePickerClose(list) {
			this.pickData.value = [];
			let item = this.pickData;
			if (list && list.length === 0) {
				if (item.templateIndex || item.templateIndex === 0) {
					this.itemList[item.index].templateList[item.templateIndex].value = '';
					this.itemList[item.index].templateList[item.templateIndex].valueName =
            '';
				} else if (item.prop === 'skuId') {
					this.itemList[item.index].partsModel = '';
					this.itemList[item.index].desc = '';
					this.itemList[item.index].otherUrl = [];
					this.itemList[item.index].skuId = '';
					this.itemList[item.index].skuName = '';
					this.itemList[item.index].spuName = '';
					this.itemList[item.index].templateList.forEach((item) => {
						item.valueName = '';
						item.value = '';
					});
					this.itemList[item.index].otherUrl = [];
				}
				this.$refs.pickPopup.close();
				return;
			}
			let val = list[0];
			console.log(val, 'val');
			console.log(item, 'this.pickData');
			if (item.templateIndex || item.templateIndex === 0) {
				this.itemList[item.index].templateList[item.templateIndex].value = val;
				this.itemList[item.index].templateList[item.templateIndex].valueName =
          item.list.find((v) => v.value === val).label;
			} else if (item.prop === 'skuId') {
				this.itemList[item.index].partsModel = '';
				this.itemList[item.index].desc = '';
				this.itemList[item.index].otherUrl = [];
				this.itemList[item.index].skuId = val;
				this.itemList[item.index].skuName = item.list.find(
					(v) => v.value === val
				).desc;
				this.itemList[item.index].spuName = item.list.find(
					(v) => v.value === val
				).spuName;
				this.itemList[item.index].isDefault = false;
				this.getSkuDetail(this.itemList[item.index], item.index);
			}
			console.log(item, 'this.pickData');
			console.log(this.itemList[item.index], 'this.itemList[item.index]');
			this.$refs.pickPopup.close();
		},
		// 点击自定义填写
		handleClickDefault(item, index) {
			if (!item.templateList) return;
			if (item.isDefault) return;
			// item.templateList.forEach(v=>{
			// 	v.disabled = false;
			// });
			item.skuId = '';
			item.skuName = '';
			item.spuName = '';
			item.otherUrl = [];
			item.templateList.forEach((v) => {
				v.value = '';
				if (v.valueName) {
					v.valueName = '';
				}
			});
			item.isDefault = !item.isDefault;
		},
		// 点击选择
		handleClickPicker(form, i, item, index) {
			if (!item.isDefault) {
				return;
			}
			this.pickData = {
				templateIndex: i,
				index: index,
				prop: form.key,
				value: form.value ? [form.value] : [],
				list: [...form.options],
				orgList: [...form.options],
				// isSearch: false,
				// searchPlaceholder: '请输入关键字搜索',
				title: '选择' + form.label,
			};
			this.$refs.pickPopup.open();
		},
		// 选择组件搜索回调
		handlePickerSearch(val) {
			console.log(val, 'handlePickerSearch');
			if (val) {
				this.pickData.list = this.pickData.orgList.filter(
					(v) => v.desc.indexOf(val) !== -1
				);
			} else {
				this.pickData.list = [...this.pickData.orgList];
			}
		},
		// 获取配件根据类目查询属性信息
		async getSkuTemplate(categoryId, index, skuId) {
			try {
				uni.showLoading({
					title: '加载中',
					mask: true,
				});
				const res = await getSkuTemplate({ categoryId: categoryId, types: 1 });
				uni.hideLoading();
				if (res.code === 200 && res.data && res.data.length) {
					console.log(res, 'getSkuTemplate');
					let list = [];
					res.data.forEach((v) => {
						let options = [];
						if (v.attrValues) {
							v.attrValues.split(',').forEach((row) => {
								options.push({
									label: row,
									value: row,
								});
							});
						}
						let value = '';
						let valueName = '';
						if (this.objData.skuPartsInfo && this.objData.skuPartsInfo.length) {
							if (this.objData.skuPartsInfo[0].label === '配件名称') {
								this.itemList[index].spuName =
                  this.objData.skuPartsInfo[0].value;
							}
							let obj = this.objData.skuPartsInfo.find(
								(row) => row.label === v.attrName
							);
							if (obj) {
								value = obj.value;
								valueName = obj.value;
							}
						}
						if (this.objData.partsList && this.objData.partsList.length) {
							if (this.objData.partsList[index].skuPartsInfo[0].label === '配件名称') {
								this.itemList[index].spuName =
                    this.objData.partsList[index].skuPartsInfo[0].value;
							}
							let obj = this.objData.partsList[index].skuPartsInfo.find(
								(row) => row.label === v.attrName
							);
							if (obj) {
								value = obj.value;
								valueName = obj.value;
							}
						}
						list.push({
							attrId: v.attrId,
							type:
                v.valueType === 0
                	? 'select'
                	: v.valueType === 1
                		? 'number'
                		: 'input',
							label: v.attrName,
							key: v.attrId,
							placeholder:
                (v.valueType === 0 ? '请选择' : '请输入') + v.attrName,
							unitName: v.unitName,
							unitCnName: v.unitCnName,
							unitType: v.unitType,
							required: v.requiredValue === 1,
							disabled: true,
							valueName: valueName,
							value: value,
							options: options,
							obj: v,
							imgs: v.imgs,
						});
					});
					if (list.length) {
						this.itemList[index].templateList = list;
						console.log(this.itemList[index], 'this.itemList[index]');
						if (this.itemList[index].skuList.length === 0) {
							this.itemList[index].isDefault = true;
						}
						this.imgList = [];
						let arr = list.filter((v) => v.imgs && v.imgs.length);
						arr.map((item) => {
							this.imgList.push({
								name: item.label,
								imgs: item.imgs,
								id: item.key,
							});
						});
						// this.imgList = arr.flat();

						console.log(arr, this.imgList, 'this.imgList');
					}
					await this.getSkuList(this.itemList[index], index);
					await this.getSkuOptions(this.itemList[index], index);
					if (skuId) {
						if (this.objData.partsList && this.objData.partsList.length) {
							if (
								!this.objData.partsList[index].skuPartsInfo ||
                  !this.objData.partsList[index].skuPartsInfo.length
							) {
								this.getSkuDetail(this.itemList[index], index);
							}
						} else {
							if (
								!this.objData.skuPartsInfo ||
                  !this.objData.skuPartsInfo.length
							) {
								this.getSkuDetail(this.itemList[index], index);
							}
						}
					} else {
						if (this.objData.partsList && this.objData.partsList.length) {
							if (
								this.objData.partsList[index].skuPartsInfo &&
                  this.objData.partsList[index].skuPartsInfo.length
							) {
								this.itemList[index].isDefault = true;
							}
						} else {
							if (
								this.objData.skuPartsInfo &&
                  this.objData.skuPartsInfo.length
							) {
								this.itemList[index].isDefault = true;
							}
						}
					}
				}
			} catch (e) {
				uni.hideLoading();
				console.log(e, 'getSkuTemplate');
			}
		},
		// 获取配件sku详情
		async getSkuDetail(item, index) {
			try {
				uni.showLoading({
					title: '加载中',
					mask: true,
				});
				let data = null;
				let obj = item.skuList.find((v) => v.value === item.skuId);
				if (obj && obj.attr) {
					data = obj;
				} else {
					const res = await getSkuDetail({ skuId: item.skuId });
					if (res.code === 200 && res.data) {
						data = res.data;
					}
				}
				uni.hideLoading();
				if (!data) return;
				if (data.picture) {
					item.otherUrl = [
						{
							type: 'image',
							url: data.picture,
						},
					];
				}
				let attr = data.attr;
				if (data.spuName) {
					item.spuName = data.spuName;
				}
				if (attr) {
					attr = JSON.parse(attr);
					attr.forEach((v) => {
						item.templateList.forEach((item) => {
							if (item.key === v.id) {
								item.valueName = v.value;
								item.value = v.value;
							}
						});
					});
				}
			} catch (e) {
				uni.hideLoading();
				console.log(e, 'getSkuTemplate');
			}
		},
		// 获取配件sku列表
		async getSkuList(item, index) {
			try {
				uni.showLoading({
					title: '加载中',
					mask: true,
				});
				let partsId = '';
				if (item.partsId) {
					let arr = [];
					if (typeof item.partsId === 'string') {
						arr = item.partsId.split(',');
					} else if (Array.isArray(item.partsId)) {
						arr = item.partsId;
					}
					partsId = arr[arr.length - 1];
				}
				let params = { elevatorId: this.objData.elevatorId, partsId };
				if (item.floorStandIds) {
					let arr = item.floorStandIds.split(',');
					params.floorStandTemplateId = arr[arr.length - 1];
				}
				const res = await getSkuList(params);
				uni.hideLoading();
				if (res.code === 200 && res.data) {
					console.log(res.data, 'getSkuList');
					console.log(item, 'item');
					// 设置配件sku选项
					let options = [];
					let partsName = '';
					if (Array.isArray(res.data) && res.data.length) {
						if (item.partsName) {
							partsName =
                item.partsName.split('>')[item.partsName.split('>').length - 1];
						}
						res.data.forEach((v) => {
							if (v.skuId === item.skuId) {
								item.skuName = v.skuInfo.replaceAll('/', ';');
							}
							options.push({
								label: partsName,
								value: v.skuId,
								desc: v.skuInfo.replaceAll('/', ';'),
							});
						});
						item.skuList = options;
						console.log(options, 'options-getSkuList');
						item.isDefault = false;
					}
				}
			} catch (e) {
				uni.hideLoading();
				console.log(e, 'getSkuList');
			}
		},
		// 获取配件sku选项
		async getSkuOptions(item, index) {
			try {
				uni.showLoading({
					title: '加载中',
					mask: true,
				});
				let partsId = '';
				if (item.partsId) {
					let arr = [];
					if (typeof item.partsId === 'string') {
						arr = item.partsId.split(',');
					} else if (Array.isArray(item.partsId)) {
						arr = item.partsId;
					}
					partsId = arr[arr.length - 1];
				}
				let params = {
					elevatorId: this.objData.elevatorId,
					partsId,
					categoryId: item.categoryId,
				};
				if (item.floorStandIds) {
					let arr = item.floorStandIds.split(',');
					params.floorStandTemplateId = arr[arr.length - 1];
				}
				const res = await getSkuOptions(params);
				uni.hideLoading();
				if (res.code === 200 && res.data) {
					console.log(res.data, 'getSkuOptions');
					console.log(item, 'item');
					// 设置配件sku选项
					if (Array.isArray(res.data) && res.data.length) {
						let options = [];
						res.data.forEach((v) => {
							let obj = item.skuList.find((row) => row.value === v.skuId);
							if (obj) {
								options.push({
									...obj,
									label: v.spuName,
									...v,
									desc: obj.desc.replaceAll(v.spuName + ';', ''),
								});
							}
						});
						item.skuList = options;
						this.sortSkuListByLabel(item.skuList);
						// res.data.forEach(v =>{
						// 	if (v.skuId === item.skuId) {
						// 		item.skuName = v.skuInfo.replaceAll('/',';');
						// 	}
						// 	options.push({
						// 		label: partsName,
						// 		value: v.skuId,
						// 		desc: v.skuInfo.replaceAll('/',';')
						// 	});
						// });
						// item.skuList = options;
						console.log(item.skuList, 'options-getSkuOptions');
						item.isDefault = false;
					} else {
						item.skuList = [];
						item.isDefault = true;
					}
				}
			} catch (e) {
				uni.hideLoading();
				console.log(e, 'getSkuList');
			}
		},
		// 点击编辑地址
		handleEditAddress() {
			this.isEditAddress = true;
			this.statusActive = this.tabIndex === 1 ? 0 : 1;
		},
		sortSkuListByLabel(skuList) {
			return skuList.sort((a, b) => {
				if (a.label < b.label) {
					return -1;
				}
				if (a.label > b.label) {
					return 1;
				}
				return 0;
			});
		},
		// 计量单位点击事件
		handleUnitClick(index) {
			this.currentUnitIndex = index;
			this.$refs.unitPopup.open();
			// 可选：初始化弹窗内容
			console.log(this.itemList,index,63255);
			this.$refs.unitDetail.init({value:this.itemList[index].unitValue,label:
				this.itemList[index].unitNameValue
			});
		},
	},
};
</script>

<style lang="scss" scoped>
page {
  background: #f5f8f9;
  // height: calc(100vh - 100rpx);
}

%widthPage {
  width: 680rpx;
  margin: 20rpx auto;
  border-radius: 8rpx;
  background-color: #ffffff;
}

@mixin fontColors($px, $count, $colour) {
  font-size: $px;
  font-weight: $count;
  color: $colour;
}

@mixin input {
  width: 100%;
  height: 80rpx;
  border: 2rpx solid #e9e9e9;
  border-radius: 4rpx;
  box-sizing: border-box;
  position: relative;
  padding: 20rpx 28rpx;
  box-sizing: border-box;
  white-space: pre-wrap;
}

.title {
  @include fontColors(28rpx, 600, #333333);
  margin: 10rpx;
  position: relative;

  .line {
    width: 4rpx;
    height: 30rpx;
    background: #0091ff;
    position: absolute;
    left: -10rpx;
    top: 8rpx;
  }
}
.nameplate {
  margin-left: 58rpx;
  margin-top: 30rpx;
  view {
    margin-bottom: 8rpx;
  }
  text {
    color: red;
  }
}
.applyPartsFixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.modelCont {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100rpx;

  view:nth-of-type(2) {
    font-size: 14px;
    text-align: center;
    color: red;
  }
}

.tabs {
  display: flex;
  // align-items: flex-end;
  justify-content: space-around;
  border-bottom: 2rpx solid #eeeeee;
  height: 74rpx;
  margin: 0 -20rpx;
  margin-bottom: 20rpx;

  &-item {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s all;
    color: #93b1c7;
    font-size: 26rpx;
    border-bottom: 4rpx solid #ffffff;
    margin: 0 20rpx;
    padding: 16rpx 0;
  }

  .act {
    border-color: #0091ff;
    color: #0091ff;
    font-size: 30rpx;
    font-weight: bold;
  }
}
.applyParts {
  background: linear-gradient(to bottom, #2c2c2c 200rpx, #f5f8f9 600rpx);
  .header {
    padding: 40rpx 20rpx;
    background: #2c2c2c;
    color: #fff;

    .name {
      font-size: 28rpx;
      font-weight: 600;
    }

    .address {
      font-size: 36rpx;
      padding-top: 4rpx;
    }
  }

  .tabs-view {
    @extend %widthPage;
    padding: 0 20rpx;
    .pAddress {
      display: flex;
      flex-direction: column;

      .add_row {
        display: flex;
        margin-left: 10rpx;

        flex-direction: column;
        margin-bottom: 20rpx;

        .cel_L {
          width: 180rpx;
          font-size: 13px;
          color: #666666;
        }

        .cel_R {
          padding: 0rpx 10rpx;
          box-sizing: border-box;
          margin: 10rpx 0 0 0;
          width: 100%;
          border: 2rpx solid #e9e9e9;
          position: relative;
          height: auto;
          border-radius: 8rpx;
          input {
            height: 68rpx;
          }

          textarea {
            width: 620rpx;
            font-size: 28rpx;
            height: 108rpx;
            padding: 10rpx 0;
          }

          .downsr {
            position: absolute;
            right: 20rpx;
            top: -8rpx;

            text {
              display: inline-block;
              width: 16rpx;
              height: 16rpx;
              border-bottom: 2rpx #ccc solid;
              border-left: 2rpx #ccc solid;
              transform: rotate(-45deg);
              margin-top: 28rpx;
            }
          }
        }
      }
    }
    .tab-header {
      display: flex;
      justify-content: space-between;
      margin: 0 -20rpx;
    }
    .tab-content {
      padding: 32rpx 4rpx;
      border-bottom-right-radius: 16rpx;
      border-bottom-left-radius: 16rpx;
      color: #333333;
      .tab-title-row {
        display: flex;
      }
      .tab-title-con {
        flex: 1;
      }
      .address-label {
        margin-top: 4rpx;
        white-space: nowrap;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 20rpx;
        padding: 4rpx;
        margin-right: 8rpx;
        color: #ffffff;
        background-color: #0091ff;
        border-radius: 2px;
        height: 28rpx;
      }
      .tab-title {
        display: flex;
        align-items: center;
        margin-bottom: 16rpx;
        .address-title {
          flex: 1;
          font-size: 32rpx;
          font-weight: 500;
        }
        .address-icon {
          width: 32rpx;
          height: 32rpx;
          image {
            width: 32rpx;
            height: 32rpx;
          }
        }
      }
    }
    .tab-clip {
      width: 0;
      height: 0;
      border-bottom: 80rpx solid transparent;
      //transition: all 0.3s ease;
    }
    .tab-clip-left {
      border-left: 0 solid transparent;
      border-right: 40rpx solid #e1e7eb;
    }
    .tab-clip-right {
      border-right: 0 solid transparent;
      border-left: 40rpx solid #e1e7eb;
    }
    .tab-item:first-child {
      padding-left: 60rpx;
      border-top-left-radius: 16rpx;
    }
    .tab-item:last-child {
      padding-right: 60rpx;
      border-top-right-radius: 16rpx;
    }
    .tab-item {
      text-align: center;
      flex: 1;
      position: relative;
      padding: 20rpx 40rpx;
      cursor: pointer;
      font-weight: 400;
      color: #999999;
      background-color: #e1e7eb;
      //transition: all 0.3s ease;
    }
    .tab-item.act {
      background-color: #ffffff;
      color: #333333;
      font-weight: 700;
      font-size: 32rpx;
    }
  }
  // height: calc(100vh - 100rpx);
  .item_parts {
    @extend %widthPage;
    padding: 20rpx;
    & > .item-content > .item-col {
      margin-bottom: 24rpx;
      .title {
        margin-bottom: 16rpx;
        display: flex;
        justify-content: space-between;
        .imgs {
          font-size: 24rpx;
          color: #0091ff;
          display: flex;
          width: 200rpx;
          justify-content: flex-end;
          align-items: center;
          image {
            width: 28rpx;
            height: 28rpx;
            margin-right: 4rpx;
          }
        }
      }
      .notes {
        margin-top: 16rpx;
        font-size: 24rpx;
        color: #999999;
      }
    }
    & > .item-content > .item-col:last-child {
      margin-bottom: 0;
    }
    .item-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 30rpx;
      .title {
        display: flex;
        align-items: center;
        margin-top: 0;
        margin-bottom: 0;
        &:before {
          content: "";
          display: inline-block;
          width: 4rpx;
          height: 28rpx;
          background-color: #0091ff;
          margin-right: 8rpx;
        }
        .serial-num {
          margin-left: 12rpx;
        }
      }
      .item-op {
        display: flex;
        align-items: center;
      }
      .del {
        margin-right: 24rpx;
        margin-top: 4rpx;
        image {
          width: 32rpx;
        }
      }
      .expanded {
        color: #0091ff;
        display: flex;
        align-items: center;
        font-size: 24rpx;
        margin-right: 20rpx;
        .downs {
          width: 14rpx;
          margin-left: 8rpx;
          line-height: 14rpx;
          margin-top: -5rpx;
          text {
            display: inline-block;
            width: 14rpx;
            height: 14rpx;
            border-bottom: 2rpx #0091ff solid;
            border-left: 2rpx #0091ff solid;
            transform: rotate(-45deg);
          }
        }
        .downs-act {
          margin-top: 10rpx;
          transform: rotate(180deg);
        }
      }
    }
    .item-title-expanded {
      margin-bottom: 0;
    }
    .title_js {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 24rpx;
      .title_text {
        font-size: 28rpx;
        font-weight: 600;
        text:nth-child(1) {
          color: red;
        }
      }
      .btn_text {
        display: flex;
        align-items: center;
        color: #0091ff;
        font-size: 24rpx;
        image {
          width: 32rpx;
          height: 32rpx;
          margin-right: 8rpx;
        }
      }
    }
    .title {
      font-size: 28rpx;
      font-weight: 600;
      margin-bottom: 24rpx;
      text:nth-child(1) {
        color: red;
      }
    }
    .parts_img {
      margin-bottom: -20rpx;
    }
    .item-input {
      //padding: 0 10rpx;
      box-sizing: border-box;
      width: 100%;
      border: 2rpx solid #e9e9e9;
      position: relative;
      height: auto;
      border-radius: 8rpx;
      .unit {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        background-color: #ffffff;
        height: 100%;
        padding: 0 20rpx;
        display: flex;
        align-items: center;
        z-index: 2;
        border-top-right-radius: 8rpx;
        border-bottom-right-radius: 8rpx;
        font-size: 26rpx;
        color: #333333;
      }
      .downs {
        margin-left: auto;
        position: absolute;
        right: 16rpx;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding-bottom: 4rpx;
        text {
          display: inline-block;
          width: 16rpx;
          height: 16rpx;
          border-bottom: 2rpx #ccc solid;
          border-left: 2rpx #ccc solid;
          transform: rotate(-45deg);
        }
      }
      input {
        height: 68rpx;
        padding: 0 20rpx;
      } 
      input[disabled] {
        background-color: #efefef; /* 自定义禁用状态下的背景颜色 */
      }
      input[readonly] {
        background-color: #ffffff; /* 只读状态保持白色背景 */
        cursor: pointer; /* 显示指针光标表示可点击 */
      }
      .unit-input[disabled]{
        background:none;
      }
      .unit-input[readonly]{
        background:none;
        cursor: pointer;
      }
      textarea {
        width: 100%;
        font-size: 28rpx;
        height: 108rpx;
        padding: 20rpx;
        position: relative;
      }
      .length {
        text-align: right;
        color: #ccc;
        position: absolute;
        right: 10rpx;
        font-size: 24rpx;
        bottom: 5rpx;
      }
      .innerText {
        padding: 0 10rpx;
        min-height: 68rpx;
        line-height: 68rpx;
      }
      .inp-disabled {
        background-color: #efefef;
      }
    }
    .btnBox {
      font-size: 28rpx;
      display: flex;
      align-items: center;
      flex-wrap: wrap;

      .btn {
        width: 33.3%;
        height: 48rpx;
        margin-bottom: 20rpx;
        display: flex;
        justify-content: center;
        align-items: center;
      }

      .btn:nth-child(3n-1) {
        justify-content: center;
      }

      .btn:nth-child(3n + 3) {
        justify-content: flex-end;
      }

      .btnItem {
        border: 2rpx solid #cccccc;
        border-radius: 8rpx;
        color: #666;
        font-size: 26rpx;
        width: 210rpx;
        padding: 16rpx 0;
        display: flex;
        justify-content: center;
        align-items: center;
      }

      .btnSel {
        border: 2rpx solid #0091ff;
        color: #0091ff;
      }
    }

    .partsNumber_inputs {
      @include input;
      margin: 28rpx 0 0 0;
    }

    .partsNumber_select {
      display: flex;
      flex-direction: row;
      margin-bottom: 32rpx;
      padding: 10rpx 20rpx;
      border: 2rpx solid #e9e9e9;
      border-radius: 8rpx;

      .innerText {
        font-size: 28rpx;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: left;
        align-items: center;
        color: #cccccc;
        line-height: 40rpx;
        width: 80%;
      }

      .partsNumber_input {
        @include input;
        margin: 28rpx 0 0 0;
        width: 630rpx;
        border-right: none;
      }

      .downs {
        width: 40rpx;
        margin-left: auto;

        text {
          display: inline-block;
          width: 16rpx;
          height: 16rpx;
          border-bottom: 2rpx #ccc solid;
          border-left: 2rpx #ccc solid;
          transform: rotate(-45deg);
        }
      }
    }
  }

  .item_partsModel {
    @extend %widthPage;
    padding: 20rpx;

    .partsNumber_input {
      @include input;
      margin: 28rpx 0 0 0;
    }

    .title {
      text {
        color: red;
      }
    }

    .notes {
      font-size: 24rpx;
      color: #999;

      text {
        display: inline-block;
        width: 50rpx;
      }
    }
  }

  .item_partsNumber {
    @extend %widthPage;
    padding: 20rpx;

    .title {
      text {
        color: red;
      }
    }

    .numBtn {
      margin-top: 20rpx;
    }
  }

  .item_partsimg {
    @extend %widthPage;
    padding: 20rpx;

    .title {
      text {
        color: red;
      }
    }

    .parts_img {
      margin-top: 20rpx;
    }
  }

  .item_remarks {
    @extend %widthPage;
    padding: 20rpx;

    .title {
      text {
        color: #999;
        font-size: 26rpx;
      }

      .rot {
        color: red;
      }
    }

    .remarks {
      width: 94%;
      padding: 20rpx;
      height: 108rpx;
      border: 2rpx solid #e9e9e9;
      border-radius: 4rpx;
      position: relative;
      padding-bottom: 30rpx;

      textarea {
        font-size: 28rpx;
        width: 100%;
        height: 108rpx;
      }

      .length {
        text-align: right;
        color: #ccc;
        position: absolute;
        right: 10rpx;
        font-size: 24rpx;
        bottom: 5rpx;
      }
    }

    .pAddress {
      display: flex;
      flex-direction: column;

      .add_row {
        display: flex;
        margin-left: 10rpx;

        flex-direction: column;
        margin-bottom: 20rpx;

        .cel_L {
          width: 180rpx;
          font-size: 13px;
          color: #666666;
        }

        .cel_R {
          height: 68rpx;
          padding: 0rpx 10rpx;
          box-sizing: border-box;
          margin: 10rpx 0 0 0;
          width: 100%;
          border: 2rpx solid #e9e9e9;
          position: relative;
          height: 100%;

          input {
            height: 100%;
          }

          textarea {
            width: 620rpx;
            font-size: 28rpx;
            height: 108rpx;
            padding: 10rpx 0;
          }

          .downsr {
            position: absolute;
            right: 20rpx;
            top: -8rpx;

            text {
              display: inline-block;
              width: 16rpx;
              height: 16rpx;
              border-bottom: 2rpx #ccc solid;
              border-left: 2rpx #ccc solid;
              transform: rotate(-45deg);
              margin-top: 28rpx;
            }
          }
        }
      }
    }
  }

  .item_information {
    @extend %widthPage;
    padding: 20rpx;

    .information_title {
      margin-top: 20rpx;

      .title_name {
        @include fontColors(24rpx, 500, #0091ff);

        text {
          display: inline-block;
          width: 16rpx;
          height: 16rpx;
          background: #0091ff;
          border-radius: 50%;
          margin-right: 10rpx;
        }
      }

      .title_uname {
        margin: 20rpx 20rpx;
        height: 48rpx;
        line-height: 48rpx;
        display: flex;

        text:nth-child(1) {
          display: inline-block;
          @include fontColors(22rpx, 500, #fff);
          text-align: center;
          width: 48rpx;
          height: 48rpx;
          background: #0091ff;
          border-radius: 50%;
        }

        text:nth-child(2) {
          display: inline-block;
          margin-left: 20rpx;
          @include fontColors(24rpx, 500, #333333);
        }
      }
    }
  }

  .item_tips {
    width: 680rpx;
    margin: 16rpx auto;
    background: #f5f8f9;
    .tips {
      @include fontColors(24rpx, 400, #999999);
    }
  }

  .BA_item_botm {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 99;
    height: 98rpx;
    display: flex;
    align-items: center;
    width: 100%;
    background: #fff;

    /* #ifdef H5 */
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    /* #endif */

    .botm {
      width: 720rpx;
      margin: 0 auto;
      height: 70rpx;
      background: #0091ff;
      border-radius: 8rpx;
      line-height: 70rpx;
      text-align: center;
      font-size: 28rpx;
      font-weight: 500;
      color: #ffffff;
    }

    .botms {
      background: #efefef;
    }
  }
}

.warning-msg {
  @extend %widthPage;
  background: #fdf1e9;
  //
  color: #fa6400;
  padding: 10rpx 20rpx;
  border-radius: 8rpx;

  &-img {
    min-width: 32rpx;
    height: 32rpx;
  }

  &-text {
    //
    display: flex;
    align-items: center;
    justify-content: space-between;
    image {
      width: 32rpx;
      height: 32rpx;
      margin-right: 8rpx;
    }
    .left {
      display: flex;
      flex: 1;
      .returnMsg {
        display: flex;
        flex: 1;
      }
    }
    .right {
      display: flex;
      width: 60rpx;
      justify-content: flex-end;
    }
  }

  .imgBox {
    image {
      width: 100%;
      margin-top: 16rpx;
      height: auto;
    }
  }
  .upTips {
    text-align: center;
    font-size: 28rpx;
  }
}

.block {
  height: 100rpx;
  width: 100%;
}
.serial-num {
  width: 40rpx;
  line-height: 40rpx;
  height: 40rpx;
  text-align: center;
  background: #dcf0ff;
  border-radius: 0px 0px 4rpx 4rpx;
  font-size: 24rpx;
  color: #0091ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color_999 {
  color: #999999 !important;
  font-size: 26rpx;
  font-weight: normal;
}
.add-btn-body {
  border-radius: 0 !important;
}
.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26rpx;
  color: #0091ff;
  .add-icon {
    width: 24rpx;
    height: 24rpx;
    margin-right: 8rpx;
  }
}
</style>
